package com.example.blogserver.controller;

import com.example.blogserver.pojo.Article;
import com.example.blogserver.pojo.User;
import com.example.blogserver.service.ArticleService;
import com.example.blogserver.a_utils.ResponseBodyMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@SuppressWarnings({"all"})
@RestController
@RequestMapping("/blog")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    /**
     * 获取文章作者信息
     */
    @RequestMapping("/AuthorMse")
    @Transactional
    public ResponseBodyMessage<User> getUserMessage(HttpServletRequest request){
        return articleService.queryUserIdByBlogId(request);
    }

    /**
     * 根据文章Id获取文章详细内容
     */
    @RequestMapping("/TextMse")
    @Transactional
    public ResponseBodyMessage<Article> getArticleMessage(HttpServletRequest request){
        return articleService.getArticleByBlogId(request);
    }

    /**
     * 对文章进行点赞
     */
    @RequestMapping("/good")
    public ResponseBodyMessage<Boolean> addGood(HttpServletRequest request){
        return articleService.addGood(request);
    }

    /**
     * 删除文章请求
     */
    @RequestMapping("/deleteBlog")
    @Transactional
    public ResponseBodyMessage<Boolean> deleteBlogByBlogId(HttpServletRequest request){
        return articleService.deleteArticleByBlogId(request);
    }

    /**
     * 审核文章
     * @param request
     * @return
     */

    @RequestMapping("/check")
    @Transactional
    public ResponseBodyMessage<String> checkArticle(HttpServletRequest request){
        return articleService.checkArticle(request);
    }
}
